package cate.game.db.facade;

import cate.game.db.mongo.MailBoxDao;
import cate.game.mail.po.MailBox;

import java.util.Optional;

public class MailBoxDaoFacade {
    public MailBoxDao dao;

    public MailBoxDaoFacade(MailBoxDao dao){
        this.dao = dao;
    }

    public MailBox find(String roleId){
        Optional<MailBox> optional = dao.findById(roleId);
        return optional.orElse(null);
    }

    public void delete(String roleId){
        dao.deleteById(roleId);
    }

    public MailBox upsert(MailBox item){
        MailBox box = null;
        try{
            box = dao.save(item);
        }catch (Exception e){
            e.printStackTrace();
        }
        return box;
    }
}
